// 解构赋值
let arr = [1,2,3];
let a = arr[0];
let b = arr[1];
let c = arr[2];
console.log(a,b,c);
let [a,b,c] = [1,2,3]; //数组的解构赋值
console.log(a,b,c);

// 对象的解构赋值：可以起给别名 = 表示默认值
let {name:userName,sex,age=18} = {name:"along",sex:"M",age:30};
console.log(userName,age)


let [[,,num3],str,{city}] = [[2,4,5],"hello",{city:"eee",address:"北三环"}];
console.log(num3)
console.log(str)
console.log(city)

// 解构应用
function ajax({url=new Error(),method="get",data={}}){
    console.log(url);
    console.log(method);
}

ajax({
    url:"baidu",
    method:"post"
})